<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改新闻</title>
</head>
<!-- css -->
<link rel="stylesheet" href="bootStrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">
<link href="https://cdn.bootcdn.net/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet">
<link href="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css"    rel="stylesheet">
<!-- js -->
<script src="js/jquery-3.7.1.js"></script>
<script src="bootStrap/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
<style>
    #title_label{
        font-size: 26px;
        color: black;
        font-family: "微软雅黑";
    }
</style>
<body>
<form method="post" action="./editorUpdate.do">
    <div class="form-group update_news">
        <label for="updateTitle" class="col-sm-1 control-label" id="title_label">标题</label>
        <div class="col-sm-11">
            <input type="text" class="form-control" id="updateTitle" name="updateTitle" value="${aNew.title}">
        </div>
    </div>
    <br />
    <br />
    <br />
    <div class="form-group">
        <div class="page-container">
            <div class="page-right">
                <!-- 编辑器 DOM -->
                <div style="border: 1px solid #ccc;">
                    <div id="editor-toolbar" style="border-bottom: 1px solid #ccc;"></div>
                    <div id="editor-text-area" style="height: 500px"></div>
                </div>
            </div>
        </div>
        <input name="updateHtml" id="updateHtml" type="text">
    </div>
    <button type="submit" name="btn_submit" id="btn_submit">提 交</button>
</form>
<script>
    const E = window.wangEditor;
    var html;

    // 切换语言
    const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
    E.i18nChangeLanguage(LANG)

    window.editor = E.createEditor({
        selector: '#editor-text-area',
        html: '<p><br></p>',
        config: {
            placeholder: '',
            MENU_CONF: {
                uploadImage: {
                    fieldName: 'file',
                    server: "./upload2.do"
                }
            },
            onChange(editor) {
                html = editor.getHtml();
                document.getElementById("updateHtml").value = html;
            }
        }
    })

    window.toolbar = E.createToolbar({
        editor,
        selector: '#editor-toolbar',
        config: {}
    })
</script>
<script>
    // 获取富文本编辑器实例
    const editor = window.editor;
    // 设置富文本框的初始值为 aNew.content
    editor.setHtml('${aNew.content}');
</script>
</body>
</html>
